package com.peng.leetcode.tiger;

import java.util.HashMap;
import java.util.Map;

/**
 * Tiger1TwoSum
 * https://leetcode-cn.com/problems/two-sum/
 *
 * @author lupeng
 * Created on 2022-04-16
 */
public class Tiger1TwoSum {

    public static void main(String[] args) {

    }

    public int[] solution(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (map.containsKey(target - num)) {
                return new int[] {i, map.get(target - num)};
            }
            map.put(num, i);
        }
        return null;
    }

}
